package permission_module.permissionmodule;

import android.Manifest;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.kalaqia.permission.aspect.NeedPermission;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.id_click).setOnClickListener(view -> {
            doScanQrCode();
        });
    }

    @NeedPermission(value = {Manifest.permission.CAMERA}, getmsg = "我们需要相机权限来扫码，以便您可以快速的使用扫码功能。")
    private void doScanQrCode() {
        Toast.makeText(this, "camera", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}
